Component({
	data: {
		active: 0,
		list: [
			{
				icon: 'home-o',
				text: '首页',
				url: '../index/index',
				pagePath: '/pages/index/index'
			},
			{
				icon: 'goods-collect-o',
				text: '商品',
				url: '../good/good',
				pagePath: '/pages/good/good'
			},
			// {
			// 	icon: 'balance-list-o',
			// 	text: '销量',
			// 	url: '../sale/sale',
			// 	pagePath: '/pages/sale/sale'
			// },
			{
				icon: 'contact',
				text: '我的',
				url: '../mine/mine',
				pagePath: '/pages/mine/mine'
			}
		]
	},
	methods: {
		onChange(event) {
			this.setData({ active: event.detail });
			
			wx.switchTab({
				url: this.data.list[event.detail].url
			});
		},

		init() {
			const page = getCurrentPages().pop();
			console.log(`/${page.route}`)
			this.setData({
				active: this.data.list.findIndex(item => item.pagePath == `/${page.route}`)
			});
			console.log(this.data.active)
		}
	}
});
